home *** CD-ROM | disk | FTP | other *** search
/ Practical Internet 2002 February / Practical Internet February 2002.iso / pc / Software / Browsing / httrack-3.09e2.exe / {app} / src_win / WinHTTrack / Wid1.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-20  |  24.9 KB  |  858 lines

  1. // Wid1.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <afxole.h>
  6. #include "oledlg.h"
  7. #include "afxodlgs.h"
  8.  
  9.  
  10. #include "Shell.h"
  11. #include "Wid1.h"
  12. //#include "filter.h"
  13.  
  14. #include "NewProj.h"
  15. #include "XSHBrowseForFolder.h"
  16.  
  17. #define HTS_WIN 1
  18. extern "C" {
  19. #include "htslib.h"
  20. }
  21.  
  22. #include "about.h"
  23. //#include "ProxyId.h"
  24. #include "InsertUrl.h"
  25.  
  26. #ifdef _DEBUG
  27. #define new DEBUG_NEW
  28. #undef THIS_FILE
  29. static char THIS_FILE[] = __FILE__;
  30. #endif
  31.  
  32. extern CNewProj* dialog0;
  33.  
  34. extern int binput(char* buff,char* s,int max);
  35.  
  36. extern int check_continue(char* path_log);
  37. //extern HICON httrack_icon;
  38. extern void linput(FILE* fp,char* s,int max);
  39. extern void linput_trim(FILE* fp,char* s,int max);
  40. extern void linput_cpp(FILE* fp,char* s,int max);
  41. extern char* fconcat(char* a,char* b);
  42. extern int cmdl_opt(char* s);
  43. extern void Write_profile(CString path,int load_path);
  44. extern void Read_profile(CString path,int load_path);
  45. //extern int suivant4(void);
  46. extern CShellApp* CShellApp_app;
  47.  
  48. // Helper
  49. extern LaunchHelp* HtsHelper;
  50.  
  51. // reference sur objet
  52. extern Wid1* dialog1;
  53.  
  54. /* Main WizTab frame */
  55. #include "WizTab.h"
  56. extern CWizTab* this_CWizTab;
  57.  
  58. /* Main splitter frame */
  59. #include "DialogContainer.h"
  60. #include "splitter.h"
  61. extern CSplitterFrame* this_CSplitterFrame;
  62.  
  63. /* Back to FirstInfo */
  64. //#include "FirstInfo.h"
  65.  
  66. // pour lire ini qu'une fois
  67. int first_time=1;
  68.  
  69. /////////////////////////////////////////////////////////////////////////////
  70. // Wid1 dialog
  71.  
  72.  
  73. /*class FileSelPath : public CFileDialog {
  74. public:
  75.   BOOL OnFileNameOK( ) { return 0; }
  76.   FileSelPath(BOOL a):CFileDialog(a) { };
  77. };*/
  78.  
  79. IMPLEMENT_DYNCREATE(Wid1, CPropertyPage)
  80.  
  81. //Cfilter filter;
  82. CString change(CString,char);
  83.  
  84. Wid1::Wid1()
  85.     : CPropertyPage(Wid1::IDD)
  86. {
  87.   dialog1=this;    /* NOTER REFERENCE */
  88.   cancel=0;
  89.     //{{AFX_DATA_INIT(Wid1)
  90.     m_C1 = -1;
  91.     m_urls = _T("");
  92.   m_todo = 0;
  93.     m_infomain = _T("");
  94.     m_filelist = _T("");
  95.     //}}AFX_DATA_INIT
  96. }
  97.  
  98. Wid1::~Wid1() {
  99.   dialog1=NULL;
  100. }
  101.  
  102. void Wid1::DoDataExchange(CDataExchange* pDX)
  103. {
  104.     CPropertyPage::DoDataExchange(pDX);
  105.     //{{AFX_DATA_MAP(Wid1)
  106.     DDX_Control(pDX, IDC_todo, m_ctl_todo);
  107.     DDX_Text(pDX, IDC_URL, m_urls);
  108.     DDX_CBIndex(pDX, IDC_todo, m_todo);
  109.     DDX_Text(pDX, IDC_INFOMAIN, m_infomain);
  110.     DDX_Text(pDX, IDC_filelist, m_filelist);
  111.     //}}AFX_DATA_MAP
  112. }
  113.  
  114. //IMPLEMENT_DYNAMIC(Wid1, CPropertyPage)
  115.  
  116. #define wm_CEasyDropTargetCallback (WM_USER + 1)
  117. BEGIN_MESSAGE_MAP(Wid1, CPropertyPage)
  118.     //{{AFX_MSG_MAP(Wid1)
  119.     ON_EN_CHANGE(IDC_URL, OnChangeUrl)
  120.     ON_CBN_SELCHANGE(IDC_todo, OnSelchangetodo)
  121.     ON_WM_CREATE()
  122.     ON_WM_HELPINFO()
  123.     ON_BN_CLICKED(ID_setopt, Onsetopt)
  124.     ON_BN_CLICKED(IDC_login2, Onlogin2)
  125.     ON_BN_CLICKED(IDC_br, Onbr)
  126.   ON_WM_DROPFILES()
  127.     ON_WM_DRAWITEM()
  128.     ON_WM_SHOWWINDOW()
  129.     ON_EN_CHANGE(IDC_filelist, OnChangefilelist)
  130.     //}}AFX_MSG_MAP
  131.     ON_COMMAND(ID_HELP_FINDER,OnHelpInfo2)
  132.     ON_COMMAND(ID_HELP,OnHelpInfo2)
  133.     //ON_COMMAND(ID_CONTEXT_HELP,OnContextHelp)
  134.     ON_COMMAND(ID_DEFAULT_HELP,OnHelpInfo2)
  135.   //
  136.   ON_BN_CLICKED(ID_LOAD_OPTIONS,OnLoadprofile)
  137.   ON_BN_CLICKED(ID_FILE_SAVE_OPTIONS_AS,OnSaveprofile)
  138.     ON_BN_CLICKED(ID_LoadDefaultOptions, OnLoaddefault)
  139.     ON_BN_CLICKED(ID_SaveDefaultOptions, OnSavedefault)
  140.     ON_BN_CLICKED(ID_ClearDefaultOptions,OnResetdefault)
  141.     //ON_BN_CLICKED(ID_NewProjectImport, OnNewProject)
  142.     ON_BN_CLICKED(ID_SaveProject, OnSaveProject)
  143.   ON_NOTIFY_EX( TTN_NEEDTEXT, 0, OnToolTipNotify )
  144.   //
  145.   ON_MESSAGE( wm_CEasyDropTargetCallback, DragDropText)
  146. END_MESSAGE_MAP()
  147.  
  148. /////////////////////////////////////////////////////////////////////////////
  149. // Wid1 message handlers
  150.  
  151. BOOL Wid1::OnInitDialog( ) {
  152.   CPropertyPage::OnInitDialog();
  153.   EnableToolTips(true);     // TOOL TIPS
  154.  
  155.   // inits aprΦs affichage
  156.   url_status=-1;
  157.   filelist_status=-1;
  158.   //prox_status=-1;
  159.   log_flip=-1;
  160.   mir_status=-1;
  161.   proj_status=-1;
  162.   continue_status=-1;
  163.   OnChangeUrl();
  164.   OnChangefilelist();
  165.   //OnChangeprox();  // update disabled/normal
  166.   //OnSelchangedepth();  // update disabled/normal
  167.   OnSelchangetodo();
  168.  
  169.   // Patcher l'interface pour les Franτais ;-)
  170.   if (LANG_T(-1)) {    // Patcher en franτais
  171.     //SetDlgItemText(,"");
  172.     SetWindowText( LANG(LANG_G30)); // "Bienvenue dans WinHTTrack!");
  173.     SetDlgItemText(IDC_STATIC_action,LANG(LANG_G31)); // "Action:");
  174.     //SetDlgItemText(IDC_STATIC_filters,LANG(LANG_G33)); // "Filtres (refuser/accepter liens) :");
  175.     SetDlgItemText(IDC_STATIC_filters2,LANG(LANG_G41)); // "Options & prefs :");
  176.     SetDlgItemText(IDC_STATIC_paths,LANG(LANG_G34)); // "Chemins");
  177.     //SetDlgItemText(IDC_regdef,LANG(LANG_G37)); // "Sauver prΘfs");
  178.     //SetDlgItemText(IDOK,LANG(LANG_NEXT )); // "SUIVANT ->");
  179.     //SetDlgItemText(IDC_avant,LANG(LANG_BACK));
  180.     //SetDlgItemText(IDCANCEL,LANG(LANG_QUIT));  // exit 
  181.     //SetDlgItemText(IDfilter,LANG(LANG_G39)); // "DΘfinir..");
  182.     SetDlgItemText(ID_setopt,LANG(LANG_G40)); // "DΘfinir les options..");
  183.     //SetDlgItemText(IDC_mirtitle2,LANG(LANG_G42)); // "Nom du projet");
  184.     SetDlgItemText(IDC_login2,LANG_G43);
  185.     //SetDlgItemText(IDC_urls,LANG_G44);
  186.     SetDlgItemText(IDC_STATIC_webaddr,LANG_G44);
  187.     SetCombo(this,IDC_todo,LISTDEF_10);
  188.   }
  189.  
  190.   // inits
  191.   LAST_ACTION = m_ctl_todo.GetCount()-1;  // dernier item (update)
  192.  
  193.   // fichier ini
  194.   // lire default
  195.   if (first_time) {
  196.     first_time=0;
  197.  
  198.     //SetDlgItemText(IDC_INFOMAIN,"Please select an action, and fill the addresse(s) in the URL box.\x0d\x0aThe mirror will be saved in the location indicated below");
  199.  
  200.     /*
  201.     CString strSection       = "DefaultValues";    
  202.     CWinApp* pApp = AfxGetApp();
  203.     CString st;
  204.     int n;
  205.     */
  206.  
  207.     /*
  208.     if ((n = pApp->GetProfileInt(strSection, "Action",CB_ERR)) != CB_ERR)
  209.       m_ctl_todo.SetCurSel(n);
  210.  
  211.     if ((st = pApp->GetProfileString(strSection, "Depth")))
  212.       SetDlgItemText(IDC_depth,st);    
  213.     */
  214.  
  215.     /*
  216.     if ((st = pApp->GetProfileString(strSection, "MirrorPath","default")) != (CString) "default")
  217.       SetDlgItemText(IDC_pthmir,st);
  218.     if ((st = pApp->GetProfileString(strSection, "LogPath","default")) != (CString) "default")
  219.       SetDlgItemText(IDC_pathlog,st);
  220.     */
  221.  
  222.     // Infos la 1ere fois!
  223.     /*if (!pApp->GetProfileInt("Interface","FirstRun",0)) {
  224.       pApp->WriteProfileInt("Interface","FirstRun",1);
  225.       Onipabout();
  226.     }*/
  227.  
  228.   } else {
  229.     log_flip=0;
  230.   }
  231.   // fichier ini  
  232.  
  233.   //OnChangepathlog();  // update rΘpertoire log
  234.   //OnChangepthmir();  // update rΘpertoire miroir
  235.  
  236.   return TRUE;
  237. }
  238.  
  239. void Wid1::AfterInitDialog( ) {
  240.   if (load_after_changes) {
  241.     AfterChangepathlog();
  242.     OnSelchangetodo();
  243.     load_after_changes=0;
  244.   }
  245.   OnChangeUrl();
  246.   OnChangefilelist();
  247. }
  248.  
  249. /*
  250. void Wid1::Onurls() {
  251.   CleanUrls();
  252. }
  253. */
  254.  
  255. // nettoyer les URLs
  256. void Wid1::CleanUrls() 
  257. {
  258.   CWaitCursor wait;
  259.   char* tempo, *ch,*str;
  260.   CString    st="";
  261.   // TODO: Add your control notification handler code here
  262.   
  263.   GetDlgItemText(IDC_URL,st);
  264.   tempo=(char*) malloc(st.GetLength()+1);
  265.   ch=(char*) malloc(st.GetLength()+1);
  266.   str=(char*) malloc(st.GetLength()*2+8192);
  267.   tempo[0]=ch[0]=str[0]='\0';
  268.   if ( (tempo) && (ch) && (str) ) {
  269.     strcpy(tempo,st);
  270.     int i;
  271.     for(i=0;i < (int) strlen(tempo);i++)  {
  272.       if(tempo[i]==10) tempo[i]=' ';
  273.       else if(tempo[i]==13) tempo[i]=' ';
  274.     }
  275.     
  276.     strcpy(ch,"");
  277.     int j=0;
  278.     for(i=0;i <= (int) strlen(tempo);i++) {
  279.       if ((tempo[i]==' ') || (tempo[i]==0)) {
  280.         ch[j++]='\0';
  281.         if ((strlen(ch)>0) && ((int) strlen(ch)<HTS_URLMAXSIZE) ) {
  282.           // vΘrifier URL
  283.           char adr[HTS_URLMAXSIZE*2],fil[HTS_URLMAXSIZE*2];
  284.           adr[0]=fil[0]='\0';
  285.           if (ident_url_absolute(ch,adr,fil)==-1) {
  286.             htsblk r;
  287.             char loc[HTS_URLMAXSIZE*2]; loc[0]='\0';    // Θventuelle nouvelle position
  288.             r=http_test(ch,fil,loc);
  289.             if ((r.statuscode==301) 
  290.               || (r.statuscode==302) 
  291.               || (r.statuscode==303) 
  292.               || (r.statuscode==307) 
  293.               || (r.statuscode==200)
  294.               ) {
  295.               strcpy(ch,loc);
  296.             }
  297.           }
  298.           
  299.           // recopier adresse
  300.           if (strstr(ch,":/")==NULL) {
  301.             strcat(str,"http://");
  302.           }
  303.           strcat(str,ch);
  304.           strcat(str,"\x0d\x0a");
  305.         }
  306.         j=0;
  307.       } else ch[j++]=tempo[i];
  308.     }
  309.     SetDlgItemText(IDC_URL,str);
  310.     free(tempo);
  311.     free(ch);
  312.     free(str);
  313.   } else
  314.     AfxMessageBox(LANG(LANG_DIAL10));
  315.   //m_urls=str;
  316. }
  317.  
  318. void Wid1::OnChangeUrl()
  319. {
  320.   CString st="";
  321.   //char tempo[8192];
  322.   char* tempo;
  323.     // TODO: If this is a RICHEDIT control, the control will not
  324.     // send this notification unless you override the CPropertyPage::OnInitDialog()
  325.     // function to send the EM_SETEVENTMASK message to the control
  326.   // with the ENM_CHANGE flag ORed into the lParam mask.
  327.   
  328.   // TODO: Add your control notification handler code here
  329.   GetDlgItemText(IDC_URL,st);
  330.   tempo=(char*) malloc(st.GetLength()+1);
  331.   if (tempo) {
  332.     strcpy(tempo,st);
  333.     int ex=0;
  334.     do {
  335.       if (strlen(tempo)>0) {
  336.         switch (tempo[strlen(tempo)-1]) {
  337.         case 10: case 13: case 32: tempo[strlen(tempo)-1]='\0';
  338.           break;
  339.         default: ex=1;
  340.           break;
  341.         }
  342.       } else ex=1;
  343.     } while(!ex);
  344.     
  345.     if ( ((strlen(tempo)>0) ) != url_status) { // || (m_ctl_todo.GetCurSel()==4)
  346.       url_status=!url_status;
  347.       
  348.       if (url_status) {
  349.         //m_ctl_next.ModifyStyle(WS_DISABLED,0);
  350.       }
  351.       else {
  352.         //m_ctl_next.ModifyStyle(0,WS_DISABLED);
  353.       }
  354.       //m_ctl_next.RedrawWindow();
  355.     }
  356.     free(tempo); tempo=NULL;
  357.   } else
  358.     AfxMessageBox(LANG(LANG_DIAL10));
  359. }
  360.  
  361. void Wid1::Refresh() {
  362.   OnChangeUrl();
  363.   //OnChangeprox();  // update disabled/normal
  364.   //OnSelchangedepth();  // update disabled/normal
  365. }
  366.  
  367. void Wid1::OnSelchangetodo() 
  368. {
  369.   int r;
  370.   r = m_ctl_todo.GetCurSel();
  371.   if (r!=CB_ERR) {
  372.     switch(r) {
  373.     case 0:
  374.       SetDlgItemText(IDC_INFOMAIN,
  375.       LANG(LANG_G2 /*"Mirror mode, fill the addresse(s) in the URL box.\x0d\x0aThe mirror will be saved in the location indicated below",
  376.       "Mode miroir, remplissez les addresse(s) dans la liste d'URLs.\x0d\x0aLe mirroir sera sauvΘ α l'emplacement indiquΘ plus bas"*/)
  377.       );
  378.       break;
  379.     case 1:
  380.       SetDlgItemText(IDC_INFOMAIN,
  381.       LANG(LANG_G3 /* "Mirror mode with wizard (asks questions), fill the addresse(s) in the URL box.\x0d\x0aThe mirror will be saved in the location indicated below",
  382.       "Mode miroir semi automatique (pose des questions), remplissez les addresse(s) dans la liste d'URLs.\x0d\x0aLe mirroir sera sauvΘ α l'emplacement indiquΘ plus bas"*/)
  383.       );
  384.       break;
  385.     case 2:
  386.       SetDlgItemText(IDC_INFOMAIN,
  387.       LANG(LANG_G4 /* "Get files mode, fill the addresse(s) of the files in the URL box.\x0d\x0aThe mirror will be saved in the location indicated below",
  388.       "Mode tΘlΘchargement de fichier, remplissez les addresse(s) des fichiers dans la liste d'URLs.\x0d\x0aLe mirroir sera sauvΘ α l'emplacement indiquΘ plus bas"*/)
  389.       );
  390.       SetDlgItemText(IDC_depth,"");
  391.       break;
  392.     case 3:
  393.       SetDlgItemText(IDC_INFOMAIN,
  394.         LANG(LANG_G1B)
  395.         );
  396.       SetDlgItemText(IDC_depth,"");
  397.       break;
  398.     case 4:
  399.       SetDlgItemText(IDC_INFOMAIN,
  400.       LANG(LANG_G5 /* "Test links mode, fill the addresse(s) of the pages containing links to test in the URL box.\x0d\x0aThe log report will be saved in the location indicated below",
  401.       "Mode test de liens, remplissez les adresse(s) des pages contenant les liens α tester dans la liste d'URLs.\x0d\x0aLes fichiers d'audit seront sauvΘs α l'emplacement indiquΘ plus bas"*/)
  402.       );
  403.       SetDlgItemText(IDC_depth,"");
  404.       break;
  405.     default:
  406.       if (r == LAST_ACTION )
  407.         SetDlgItemText(IDC_INFOMAIN,
  408.         LANG(LANG_G6 /* "Update/Continue a mirror mode, check addresse(s) in the URL box, then click to the 'NEXT' button and check parameters.\x0d\x0aThe mirror will be saved in the location indicated below",
  409.         "Mode mise α jour/continuer un miroir, vΘrifiez les adresse(s) dans la liste d'URLs, puis cliquez sur le bouton 'NEXT' et vΘrifiez les paramΦtres.\x0d\x0aLe mirroir sera sauvΘ α l'emplacement indiquΘ plus bas"*/)
  410.         );
  411.       else if (r == LAST_ACTION-1 )
  412.         SetDlgItemText(IDC_INFOMAIN,
  413.         LANG(LANG_G6b /* "Update/Continue a mirror mode, check addresse(s) in the URL box, then click to the 'NEXT' button and check parameters.\x0d\x0aThe mirror will be saved in the location indicated below",
  414.         "Mode mise α jour/continuer un miroir, vΘrifiez les adresse(s) dans la liste d'URLs, puis cliquez sur le bouton 'NEXT' et vΘrifiez les paramΦtres.\x0d\x0aLe mirroir sera sauvΘ α l'emplacement indiquΘ plus bas"*/)
  415.         );
  416.       break;
  417.     }
  418.     
  419.     if ( ((r==LAST_ACTION)||(r==LAST_ACTION-1)) != continue_status) {
  420.       continue_status=((r==LAST_ACTION)||(r==LAST_ACTION-1));
  421.       OnChangeUrl();
  422.     }
  423.   }
  424.   
  425. }
  426.  
  427.  
  428. void Wid1::OnChangepathlog() {
  429.   load_after_changes=1;
  430. }
  431.  
  432. void Wid1::AfterChangepathlog() 
  433. {
  434.   CString st="";
  435.   char tempo[8192];
  436.   BOOL modify;
  437.  
  438.   strcpy(tempo,dialog0->GetPath());
  439.   {
  440.     if (fexist(fconcat(tempo,"hts-cache/winprofile.ini"))) {    // un cache est prΘsent
  441.       if (fsize(fconcat(tempo,"hts-cache/winprofile.ini"))>0) {   // taille log contr⌠le>0
  442.         int i;
  443.         for(i=0;i<(int) strlen(tempo);i++)
  444.           if (tempo[i]=='/')
  445.             tempo[i]='\\';
  446.           Read_profile(fconcat(tempo,"hts-cache\\winprofile.ini"),0);
  447.  
  448.           // peut on modifier?
  449.           int pos=m_ctl_todo.GetCurSel();
  450.           if ((pos==LAST_ACTION) || (pos==LAST_ACTION-1) || (pos==0))
  451.             modify=true;
  452.           else
  453.             modify=false;
  454.           
  455.           // existe: update
  456.           if ((fexist(fconcat(tempo,"hts-cache/new.dat"))) && (fexist(fconcat(tempo,"hts-cache/new.ndx")))) {  // il existe dΘja un cache prΘcΘdent.. renommer
  457.             if (modify) {
  458.               if (
  459.                 (!fexist(fconcat(tempo,"hts-in_progress.lock")))
  460.                 &&
  461.                 (!fexist(fconcat(tempo,"hts-cache/interrupted.lock")))
  462.                 )
  463.                 m_ctl_todo.SetCurSel(LAST_ACTION);
  464.               else
  465.                 m_ctl_todo.SetCurSel(LAST_ACTION-1);
  466.             }
  467.             log_flip=1;
  468.           } else if (log_flip) {
  469.             if (modify)
  470.               m_ctl_todo.SetCurSel(0);
  471.             log_flip = 0;
  472.           }
  473.           OnSelchangetodo();
  474.       }
  475.     } else if (log_flip) {
  476.       m_ctl_todo.SetCurSel(0);
  477.       log_flip = 0;
  478.     }
  479.   }
  480. }
  481. /*
  482. void Wid1::OnClose() 
  483. {
  484.   // TODO: Add your message handler code here and/or call default
  485.   //Onfin();
  486.   //::OnClose();
  487.   if (AfxMessageBox(
  488.   LANG(LANG_J1)
  489.   ,MB_OKCANCEL)==IDOK) {
  490.     if (Save_current_profile(1)!=IDCANCEL) {
  491.       cancel=1;
  492.       CPropertyPage::OnCancel();
  493.     }
  494.   }
  495. }
  496. */
  497.  
  498.  
  499.  
  500. // ------------------------------------------------------------
  501. // TOOL TIPS
  502. //
  503. // ajouter dans le .cpp:
  504. // remplacer les deux Wid1:: par le nom de la classe::
  505. // dans la message map, ajouter
  506. // ON_NOTIFY_EX( TTN_NEEDTEXT, 0, OnToolTipNotify )
  507. // dans initdialog ajouter
  508. // EnableToolTips(true);     // TOOL TIPS
  509. //
  510. // ajouter dans le .h:
  511. // char* GetTip(int id);
  512. // et en generated message map
  513. // afx_msg BOOL OnToolTipNotify( UINT id, NMHDR * pNMHDR, LRESULT * pResult );
  514. BOOL Wid1::OnToolTipNotify( UINT id, NMHDR * pNMHDR, LRESULT * pResult )
  515. {
  516.   TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;
  517.   UINT nID =pNMHDR->idFrom;
  518.   if (pTTT->uFlags & TTF_IDISHWND)
  519.   {
  520.     // idFrom is actually the HWND of the tool
  521.     nID = ::GetDlgCtrlID((HWND)nID);
  522.     if(nID)
  523.     {
  524.       char* st=GetTip(nID);
  525.       if (st != "") {
  526.         pTTT->lpszText = st;
  527.         pTTT->hinst = AfxGetResourceHandle();
  528.         return(TRUE);
  529.       }
  530.     }
  531.   }
  532.   return(FALSE);
  533. }
  534. char* Wid1::GetTip(int ID)
  535. {
  536.   switch(ID) {
  537.     case IDC_todo:  return LANG(LANG_G9); break; // "Choose an action","Choisissez une action"); break; 
  538.     case IDC_depth: return LANG(LANG_G10); break; // "Maximum link depth to scan","Profondeur maximale"); break;
  539.     case IDC_URL:   return LANG(LANG_G11); break; // "Enter addresses here","Entrez les adresses ici"); break;
  540.     //case IDC_urls:  return LANG(LANG_G12); break; // "Check spelling","VΘrifier syntaxe"); break;
  541.     //case IDfilter:  return LANG(LANG_G13); break; // "Define additional filters","DΘfinir les filtres supplΘmentaires"); break;
  542.     //case IDC_pathlog:  return LANG(LANG_G16); break; // "Path","Chemin"); break;
  543.     //case IDC_br2:      return LANG(LANG_G17); break; // "Select path","Choix du chemin"); break;
  544.     //case IDC_pthmir:   return LANG(LANG_G18); break; // "Path","Chemin"); break;
  545.     //case IDC_br1:      return LANG(LANG_G19); break; // "Select path","Choix du chemin"); break;
  546.     case IDCANCEL:     return LANG(LANG_G20); break; // "Quit WinHTTrack","Quittter WinHTTrack"); break;
  547.     case IDC_ipabout:  return LANG(LANG_G21); break; // "About WinHTTrack","A propos de WinHTTrack"); break;
  548.     case IDC_regdef:   return LANG(LANG_G22); break; // "Save preferences as default values","Sauver les rΘglages par dΘfaut"); break;
  549.     case IDOK:         return LANG(LANG_G23); break; // "Click to continue","Clic pour continuer"); break;
  550.     case IDC_avant:     return LANG_TIPPREV; break;
  551.     case ID_setopt:    return LANG(LANG_G24); break; // "Click to define option","Clic pour dΘfinir les options"); break;
  552.     case IDC_login2:   return LANG_G24b; break;
  553.     case IDC_filelist: return LANG_G24c; break;
  554.     //case : return ""; break;
  555.   }
  556.   return "";
  557. }
  558. // TOOL TIPS
  559. // ------------------------------------------------------------
  560.  
  561.  
  562. /*
  563. void Wid1::OnDropFiles(HDROP hDropInfo) 
  564. {
  565.   int nf;
  566.   int i;
  567.   nf=DragQueryFile(hDropInfo,0xFFFFFFFF,NULL,0);    // nbre de fichiers
  568.  
  569.   for(i=0;i<nf;i++) {
  570.     char* buff;
  571.     int size;
  572.     size=DragQueryFile(hDropInfo,i,NULL,0);    // taille buffer nΘcessaire
  573.     if (size>0) {
  574.       size+=16;    // marge de sΘcuritΘ
  575.       buff=(char*) calloc(size,1);
  576.       if (buff) {
  577.         if (DragQueryFile(hDropInfo,i,buff,size)>0) {    // ok copiΘ
  578.           AfxMessageBox(buff,MB_OKCANCEL+MB_ICONQUESTION);
  579.         }
  580.         free(buff);
  581.       }
  582.     }
  583.   }
  584.  
  585.   CPropertyPage::OnDropFiles(hDropInfo);
  586. }
  587. */
  588.  
  589. int Wid1::OnCreate(LPCREATESTRUCT lpCreateStruct) 
  590. {
  591.     if (CPropertyPage::OnCreate(lpCreateStruct) == -1)
  592.         return -1;
  593.  
  594.   // Drag&Drop
  595.   drag=new CEasyDropTarget(this);
  596.   if (drag->IsRegistered()) {
  597.     drag->SetTextCallback(wm_CEasyDropTargetCallback);
  598.   }
  599.     
  600.     return 0;
  601. }
  602.  
  603.  
  604. CString Wid1::TextToUrl(CString st,CLIPFORMAT cfFormat) {
  605.   // yop
  606.   // on va convertir les chaines α la suite
  607.   if (cfFormat==CF_TEXT) {
  608.     char *buff;
  609.     buff=(char*) malloc(st.GetLength()+2);
  610.     if (buff) {
  611.       char s[HTS_URLMAXSIZE*2];
  612.       CString res="";
  613.       strcpy(buff,st);
  614.       //
  615.       int ptr=0;
  616.       do {
  617.         ptr+=binput(buff+ptr,s,1000);
  618.         if (!strstr(s,"://")) {
  619.           char tempo[HTS_URLMAXSIZE*2]="http://";
  620.           strcat(tempo,s);
  621.           strcpy(s,tempo);
  622.         }
  623.         escape_check_url(s);
  624.         if (res.GetLength())
  625.           res+="\r\n";
  626.         res+=s;
  627.       } while(ptr<(int) strlen(buff));
  628.       st=res;
  629.       free(buff);
  630.     }
  631.   }
  632.   else if (cfFormat==CF_HDROP) {
  633.     if (st.GetLength()<256) {
  634.       char s[256];
  635.       strcpy(s,st);
  636.       escape_check_url(s);     // coder %
  637.       st="file://";
  638.       st+=s;
  639.     } else
  640.       st="";
  641.   }
  642.   else
  643.     st="";
  644.   return st;
  645. }
  646.  
  647. // Message from CEasyDropTarget
  648. LRESULT Wid1::DragDropText(WPARAM wParam,LPARAM lParam) {
  649.   if (lParam) {
  650.     CString st=*((CString*) lParam);
  651.     CLIPFORMAT cfFormat=wParam;
  652.     st=Wid1::TextToUrl(st,cfFormat);
  653.     if (st=="")
  654.       AfxMessageBox(LANG(LANG_DIAL11),MB_SYSTEMMODAL);
  655.     else
  656.       AddText(st);
  657.   }
  658.   return 0;
  659. }
  660.  
  661. // ajout d'URLs
  662. void Wid1::AddText(CString add_st) {
  663.   CString st;
  664.   GetDlgItemText(IDC_URL,st);
  665.   SetDlgItemText(IDC_URL,st+"\r\n"+add_st);
  666.   CleanUrls();
  667.   OnChangeUrl();
  668. }
  669.  
  670. // Appel aide
  671. BOOL Wid1::OnHelpInfo2() {
  672.   return OnHelpInfo(NULL);
  673. }
  674.  
  675. BOOL Wid1::OnHelpInfo(HELPINFO* dummy) 
  676. {
  677.   //return CPropertyPage::OnHelpInfo(pHelpInfo);
  678.   //AfxGetApp()->WinHelp(0,HELP_FINDER);    // Index du fichier Hlp
  679.   //LaunchHelp(pHelpInfo);
  680.   HtsHelper->Help("step2.html");
  681.   //HtsHelper->Help();
  682.   return true;
  683. }
  684.  
  685. void Wid1::OnLoadprofile() {
  686.   static char BASED_CODE szFilter[256];
  687.   strcpy(szFilter,LANG(LANG_G25 /*"WinHTTrack preferences (*.opt)|*.opt||","RΘglages de WinHTTrack (*.opt)|*.opt||"*/));
  688.   CFileDialog* dial = new CFileDialog(true,"opt",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,szFilter);
  689.   if (dial->DoModal() == IDOK) {
  690.     CString st=dial->GetPathName();
  691.     char s[256];
  692.     strcpy(s,st);
  693.     if (fexist(s))
  694.       Read_profile(st,1);
  695.     else
  696.       AfxMessageBox(LANG(LANG_G26 /*"File not found!","Fichier introuvable!"*/));
  697.   }
  698.   delete dial;
  699. }
  700.  
  701. void Wid1::OnSaveprofile() {
  702.   static char BASED_CODE szFilter[256];
  703.   strcpy(szFilter,LANG(LANG_G25 /*"WinHTTrack preferences (*.opt)|*.opt||","RΘglages de WinHTTrack (*.opt)|*.opt||"*/));
  704.   CFileDialog* dial = new CFileDialog(false,"opt",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,szFilter);
  705.   if (dial->DoModal() == IDOK) {
  706.     CString st=dial->GetPathName();
  707.     Write_profile(st,1);
  708.   }
  709.   delete dial;
  710. }
  711.  
  712. void Wid1::OnLoaddefault() {
  713.   if (AfxMessageBox(LANG(LANG_G27),MB_OKCANCEL)==IDOK) {
  714.     Read_profile("",0);
  715.   }
  716. }
  717.  
  718. void Wid1::OnSavedefault() {
  719.   if (AfxMessageBox(LANG(LANG_G28),MB_OKCANCEL)==IDOK) {
  720.     Write_profile("",0);
  721.   }
  722. }
  723.  
  724. void Wid1::OnResetdefault() {
  725.   if (AfxMessageBox(LANG(LANG_G29),MB_OKCANCEL)==IDOK) {
  726.     Read_profile("<null>",0);    // charger default
  727.     Write_profile("",0);         // et sauver
  728.   }
  729. }
  730.  
  731. /*
  732. void Wid1::OnNewProject() {
  733.   if (AfxMessageBox(LANG(LANG_G1C),MB_OKCANCEL)==IDOK) {
  734.     CWinApp* pApp = AfxGetApp();
  735.     CString name = pApp->m_pszHelpFilePath;
  736.     name=name.Left(name.GetLength()-4);
  737.     name += ".EXE";
  738.     ShellExecute(NULL,"open",name,"","",SW_RESTORE);
  739.     cancel=1;
  740.     EndDialog(1);
  741.   }
  742. }
  743. */
  744.  
  745. void Wid1::OnSaveProject() {
  746.   Save_current_profile(0);
  747. }
  748.  
  749. void Wid1::Onsetopt() 
  750. {
  751.   CShellApp_app->OptPannel();
  752. }
  753.  
  754. /*
  755. HCURSOR Wid1::OnQueryDragIcon() 
  756. {
  757.     // TODO: Add your message handler code here and/or call default
  758.     
  759.     return CPropertyPage::OnQueryDragIcon();
  760. }
  761. */
  762.  
  763. void Wid1::Onlogin2() 
  764. {
  765.   CInsertUrl url;
  766.   url.dest_path=dialog0->GetPath();
  767.   if (url.DoModal() == IDOK) {
  768.     if (url.m_urladr.Left(7)=="http://")
  769.       url.m_urladr=url.m_urladr.Mid(7);
  770.     CString st;
  771.     GetDlgItemText(IDC_URL,st);
  772.     if (url.m_urllogin.GetLength()==0) {
  773.       SetDlgItemText(IDC_URL,st+"\r\n"+url.m_urladr);
  774.     } else {
  775.       char *a,*b;
  776.       escape_in_url(a=copychar(LPCTSTR(url.m_urllogin)));
  777.       escape_in_url(b=copychar(LPCTSTR(url.m_urlpass)));
  778.       SetDlgItemText(IDC_URL,st+"\r\n"+(CString)(a)+":"+(CString)(b)+"@"+url.m_urladr);
  779.     }
  780.     CleanUrls();
  781.     OnChangeUrl();
  782.   }
  783. }
  784.  
  785. LRESULT Wid1::OnWizardNext() {
  786.   CString st;
  787.   UpdateData(TRUE);         // DoDataExchange
  788.   m_urls.TrimLeft(); m_urls.TrimRight();
  789.   m_filelist.TrimLeft(); m_filelist.TrimRight();
  790.   if ((m_urls.GetLength()>0) || (m_filelist.GetLength()>0)) {
  791.     if ((m_todo==LAST_ACTION)||(m_todo==LAST_ACTION-1)) {
  792.       char path[HTS_URLMAXSIZE*2];
  793.       CString st;
  794.       st=dialog0->GetPath();
  795.       strcpy(path,st);
  796.       if (check_continue(path))
  797.         return 0;
  798.       else {
  799.         GetDlgItem(IDC_URL)->SetFocus();
  800.         return -1;        // impossible de continuer
  801.       }
  802.     }
  803.   } else {
  804.     GetDlgItem(IDC_URL)->SetFocus();
  805.     return -1;
  806.   }
  807.   return 0;
  808. }
  809.  
  810. BOOL Wid1::OnSetActive( ) {
  811.   //OnInitDialog();
  812.   AfterInitDialog();
  813.   this_CWizTab->SetWizardButtons(PSWIZB_BACK|PSWIZB_NEXT);
  814.   return 1;
  815. }
  816.  
  817. BOOL Wid1::OnQueryCancel( ) {
  818.   this_CSplitterFrame->SetNewView(0,1,RUNTIME_CLASS(CDialogContainer));
  819.   return 0;
  820. }
  821.  
  822. BOOL Wid1::OnKillActive( ) {
  823.   UpdateData(TRUE);         // DoDataExchange
  824.   return 1;
  825. }
  826.  
  827. void Wid1::Onbr() 
  828. {
  829.   static char BASED_CODE szFilter[256];
  830.   strcpy(szFilter,LANG(LANG_G25b));
  831.   CFileDialog* dial = new CFileDialog(true,"txt",NULL,OFN_HIDEREADONLY,szFilter);
  832.   if (dial->DoModal() == IDOK) {
  833.     if (fexist((char*)LPCSTR(dial->GetPathName()))) {
  834.       SetDlgItemText(IDC_filelist,dial->GetPathName());
  835.     } else {
  836.       AfxMessageBox(LANG(LANG_G26 /*"File not found!","Fichier introuvable!"*/));
  837.       SetDlgItemText(IDC_filelist,"");
  838.     }
  839.   }
  840.   delete dial;
  841.   OnChangefilelist();
  842. }
  843.  
  844. void Wid1::OnChangefilelist() 
  845. {
  846.   CString st;
  847.   GetDlgItemText(IDC_filelist,st);
  848.   if ((st.GetLength()>0) != filelist_status) {
  849.     filelist_status=(st.GetLength()>0);
  850.     if (filelist_status) {
  851.       GetDlgItem(IDC_STATIC_filelist)->ModifyStyle(WS_DISABLED,0);
  852.     } else {
  853.       GetDlgItem(IDC_STATIC_filelist)->ModifyStyle(0,WS_DISABLED);
  854.     }
  855.     GetDlgItem(IDC_STATIC_filelist)->RedrawWindow();
  856.   }
  857. }
  858.